<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		
	  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
	  <!-- Ionicons -->
	  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
	  <!-- Theme style -->
	  <link rel="stylesheet" href="../../dist/css/adminlte.min.css">
	  <!-- Google Font: Source Sans Pro -->
	  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">		
		
	</head>
	
	<body>
		<center>
				<br />
				<table border="0" align="center" width="900" >
					
					<tr>
						<td colspan="6">
							<h3 align="left">寄件人信息</h3>
							<hr />							
						</td>
					</tr>
					
					<tr>
						<td align="right">
							<label for="exampleInputEmail1">姓名: &nbsp; &nbsp;</label>
						</td>
						<td width="240" height="60">
							<input type="text" class="form-control" name="senderinformation" id="senderinformation" style="width: 240px;" onblur="fun4()" placeholder="只能输入 7 以内的字符" />
						</td>
						<td><span id="div4"></span></td>
						<td align="right">
							<label for="exampleInputEmail1"><span style="color: #FF0000;">*&nbsp;</span>联系方式:&nbsp; &nbsp;</label>
						</td>
						<td width="240" height="60">
							<input type="text" class="form-control" name="sendercontactway" id="sendercontactway" oninput="fun1()" placeholder="请输入 6 位  或 11 位 联系方式" />
						</td>
						<td width="100">
							<div id="div1"></div>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label for="exampleInputEmail1"><span style="color: #FF0000;">*&nbsp;</span>重量: &nbsp; &nbsp;</label>
						</td>
						<td width="240" height="60">
							<input type="text" class="form-control" name="weight" id="weight" placeholder="单位 (kg)" oninput="fun2()" />
						</td>
						<td width="80">
							<div id="div2"></div>
						</td>
						<td align="right">
							<label for="exampleInputEmail1">预计到达日期:&nbsp; &nbsp;</label>
						</td>
						<td width="240" height="60">
							<input type="date" class="form-control" name="required_date"  id="required_date" />
						</td>
						<td></td>
					</tr>
					<tr>
						<td align="right">
							<label for="exampleInputEmail1">寄件地址: &nbsp; &nbsp;</label>
						</td>
						<td width="240" height="60">
							<input type="text" class="form-control" name="cargoinformation" id="cargoinformation" style="width: 240px;" />
						</td>
						<td>&nbsp;</td>
						<td align="right">
							<label for="exampleInputEmail1">收件地址: &nbsp; &nbsp;</label>
						</td>
						<td width="240" height="60">
							<input type="text" class="form-control" name="placeofdeparture" id="placeofdeparture" oninput="searchByStationName();" />
						</td>
						<td></td>
					</tr>
				</table>
				
				
				<br />
				<table border="0" align="center" width="900" >
					<tr>
						<td colspan="6">
							<h3 align="left">收件人信息: &nbsp; &nbsp;</h3>
							<hr />							
						</td>
					</tr>
					<tr>
						<td align="right">
							<label for="exampleInputEmail1">姓名: &nbsp; &nbsp;</label>
						</td>
						<td width="240" height="60">
							<input type="text" class="form-control" name="consigneeinformation" id="consigneeinformation" onblur="fun5()" placeholder="只能输入 7 以内的字符" />
						</td>
						<td width="80"><span id="div5"></span></td>
						<td align="right" width="135">
							<label for="exampleInputEmail1"><span style="color: #FF0000;">*&nbsp;</span>联系方式: &nbsp; &nbsp;</label>
						</td>
						<td width="240" height="60">
							<input type="text" class="form-control" name="concontactway" id="concontactway" oninput="fun3()" placeholder="请输入 6 位  或 11 位 联系方式"/>
						</td>
						<td width="100">
							<div id="div3"></div>
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center" >
							<br />
							<label for="exampleInputEmail1">总价:&nbsp; &nbsp;<span id="zhongjia"><span style='color: #FF0000;'>0&nbsp;元</span></span></label>
						</td>
						<td></td>
						<td align="right">
							<label for="exampleInputEmail1"><span style="color: #FF0000;">*&nbsp;</span>货物类型: &nbsp; &nbsp;</label>
						</td>
						<td>
							<input type="text" class="form-control" name="ordertype" id="ordertype"/>
						</td>
						<td></td>
					</tr>
				</table>
						<br /><br />
						<button class="btn btn-primary" onclick="AddSendasingle()" >确认下单</button>
		</center>
		
		
		
		
		
		<!-- 地图  display: none; 隐藏状态   -->
		<div id="container" style="position: absolute;
			display: none;
            margin-top:20px; 
            width: 600px; 
            height: 290px; 
            top: 50; 
            border: 1px solid gray;
            overflow:hidden;">
		</div>	 

			

		
		
	<!-- jQuery -->
	<script src="../../plugins/jquery/jquery.min.js"></script>
	<!-- Bootstrap 4 -->
	<script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
	<!-- FastClick -->
	<script src="../../plugins/fastclick/fastclick.js"></script>
	<!-- AdminLTE App -->
	<script src="../../dist/js/adminlte.min.js"></script>
	<!-- AdminLTE for demo purposes -->
	<script src="../../dist/js/demo.js"></script>
	<!-- 地图 -->
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=Nsbrrt0AKiMM8QmTaQp4iLby9DtiSWSf"></script>
	<!-- 自定义的 js 文件  -->
	<script type="text/javascript" src="js/express.js"></script>	
	<script>
		
	// 表单的状态
	var stat = true;

	//经度 longitude  纬度 latitude
	var longitude = 0; //经度
	var latitude = 0;  //纬度
	var totalvalue = 0; //总价
	function AddSendasingle(){
		var	placeofdeparture = $("#placeofdeparture").val(); //收件地址 （向数据库添加 经度 longitude  纬度 latitude）
		var	sendercontactway = $("#sendercontactway").val(); //寄件人联系方式 ？
		var	concontactway  = $("#concontactway").val(); //收件人联系方式 ？
		var senderinformation = $("#senderinformation").val(); //寄件人信息 （姓名）
		
		var	cargoinformation = $("#cargoinformation").val(); //寄件地址 ？
		var	consigneeinformation =$("#consigneeinformation").val(); //收件人信息 （姓名）
		var	required_date = $("#required_date").val(); //预计到达日期
		var weight = $("#weight").val(); //重量
		var ordertype = $("#ordertype").val(); //货物类型
		
		if(placeofdeparture == "" || sendercontactway == "" || concontactway == "" || cargoinformation == "" || consigneeinformation == "" || required_date == "" || ordertype ==""){ //收件地址
			stat = false;
		}else{
			stat = true;
		}
		
		if(placeofdeparture != 0 && cargoinformation != 0){
		    if(stat == true){
				if(placeofdeparture == cargoinformation){
					alert("收件地址  和  寄件地址不能相同");
				}else{
					alert("预计到达时间："+required_date);
			    	$.ajax({
						type:"post",
				    	url:"http://127.0.0.1:8075/SaveSendasingle",
				    	xhrFields:{withCredentials: true},
				    	crossDomain: true,
				    	dataType:"json",
				    	data:{"placeofdeparture":placeofdeparture,"sendercontactway":sendercontactway,"concontactway":concontactway,
				    	"cargoinformation":cargoinformation,"consigneeinformation":consigneeinformation,"required_date":required_date,
				    	"longitude":longitude,"latitude":latitude,"totalvalue":totalvalue,"senderinformation":senderinformation,"ordertype":ordertype},
				    	success:function(msg){
				    		alert(msg);
				    	}
			    	});						
				}
		    }else{
		    	alert("请填写有效完整的数据");
		    }
		}else{
			alert("请填写有效完整的数据");
		}
		
	}		
		
	</script>

	

	</body>
</html>
